
require 'date'

module Raklur

	#
	# Abstract class for timeline
	#
	class Timeline
		# public infos
		attr_accessor :update_interval, :title, :url

		# account containing this timeline
		attr_reader :account


		# Return whether update is possible
		#
		def update?
			raise NotImplementedError
		end


		# Get new update timestamp
		# 
		def next_update
			latest = if @latest_update.nil? then Time.now
					 else @latest_update
					 end
			( latest + @update_interval )
		end


		# Update timeline now
		#
		def update!
			raise NotImplementedError
		end


		# Info about current timeline
		#
		def to_s
			return "%s : %s (next in %s)" % [ @account.title, @title, (next_update - Time.now) .to_i ]
		end


		private


		# Make abstract
		#
		def initialize account, title=nil, url=nil
			raise NotImplementedError
		end
	end
end

